let index_fn = async (ctx,next)=>{
    ctx.body=`
<center>
    <form action="/loginDone" method="post">
    <table>
<tr>
    <td>
        用户名：
    </td>
    <td>
        <input type="text" name="username">
    </td>
</tr>
    
<tr>
    <td>
            密码：
    </td>
    <td>
        <input type="password" name="password">
    </td>

</tr>
    </table>
        <input type="submit" value="登录">
    </form><br>

    <a href="/">
    <button>点击返回首页</button>
    </a>
    <br> 
<center>
    
    ` ;
}

let home_fn = async (ctx,next)=>{
    ctx.body =`
    <center>
    <h2>欢迎来到首页界面，你可以点击下面的按钮前往登录界面进行登录</h2><br>
    
    <a href="/login">
    <button>点点点</button>
    </a>
    </center>
    `;
}

let login_fn = async (ctx,next)=>{
    let userName = ctx.request.body.username || '';
    let passWord = ctx.request.body.password || '';

    if(userName === 'root' && passWord === '123456'){
        ctx.response.body='登陆成功'
    }else{
        ctx.response.body = '用户名或密码错误，请确认后重试';
    }
}


module.exports={
    '/':['get',home_fn],
    '/login':['get',index_fn],
    '/loginDone':['post',login_fn]    
}